home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / fortran.zip / SBM.LST < prev    next >
File List  |  1991-01-10  |  56KB  |  1,511 lines

  1.     
  2.     
  3.     
  4.     
  5.     
  6.     
  7.     
  8.     
  9.     
  10.     
  11.     
  12.     
  13.     
  14.     
  15.     
  16.     
  17.     
  18.     
  19.     
  20.     
  21.                              S B M     F O R T R A N
  22.     
  23.                               A FORTRAN answer to 'C'
  24.     
  25.     
  26.     
  27.     
  28.     
  29.                     The best road is designed by the traveller.
  30.     
  31.     
  32.     
  33.     
  34.     
  35.     
  36.                            Copyright (c) 1989-1991 by
  37.     
  38.                                    DUKE DAIGH
  39.     
  40.                           Pine Bluffs, Wyoming 82082-0631
  41.  
  42.     
  43.     
  44.                                    DISCLAIMER
  45.     
  46.     
  47.     
  48.         This is the initial release of SBM FORTRAN.  It is probable that there
  49.         are bugs.  It may NEVER be totally bug-free.  For this reason we make
  50.         the following statement.
  51.    
  52.         This program is supplied as-is.  The author disclaims all warranties,
  53.         expressed or implied. The author assumes no liability for damages which
  54.         might result from the use of this program.
  55.    
  56.         You are encouraged to freely distribute this package.  Mail copies to
  57.         friends.  Put  it up on other boards.  We only request that you
  58.         distribute only unmodified copies.
  59.    
  60.    
  61.         Direct all inquiries, suggestions, etc. to:
  62.    
  63.                             Duke Daigh
  64.                             P.O. Box 631
  65.                             Pine Bluffs, Wyoming  82082-0631
  66.  
  67.  
  68.                                   CONTENTS
  69.  
  70.     Introduction to SBM fortran. . . . . . . . . . . . . . . . . . . . iii
  71.     Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iv
  72.     Current status . . . . . . . . . . . . . . . . . . . . . . . . . . v
  73.  
  74.     Fortran statements . . . . . . . . . . . . . . . . . . . . . . . . 1-1
  75.     Statement lables . . . . . . . . . . . . . . . . . . . . . . . . . 1-1
  76.     Symbolic names and keywords  . . . . . . . . . . . . . . . . . . . 1-1
  77.     Statement order  . . . . . . . . . . . . . . . . . . . . . . . . . 1-1
  78.  
  79.     Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
  80.     Include  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
  81.  
  82.     Data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
  83.              Byte, Character, Integer*1, Logical . . . . . . . . . . . 1-3
  84.              Word, Integer, Integer*2  . . . . . . . . . . . . . . . . 1-3
  85.              Doubleword, Integer*4 . . . . . . . . . . . . . . . . . . 1-3
  86.              Character strings, ASCIIZ . . . . . . . . . . . . . . . . 1-3
  87.  
  88.     Quoted strings . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
  89.     Data declaration and initialization  . . . . . . . . . . . . . . . 1-5
  90.     Data statement . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5
  91.  
  92.     OPEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1
  93.              UNIT (5-255). . . . . . . . . . . . . . . . . . . . . . . 2-1
  94.              IOCB names  . . . . . . . . . . . . . . . . . . . . . . . 2-1
  95.              FILE  . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1
  96.              ALIAS (alternate name for io unit). . . . . . . . . . . . 2-1
  97.              STATUS (old, new, append) . . . . . . . . . . . . . . . . 2-1
  98.              RECL  . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1
  99.  
  100.     READ STATEMENTS  . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
  101.            Unformatted . . . . . . . . . . . . . . . . . . . . . . . . 2-3
  102.            formatted . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
  103.            List directed . . . . . . . . . . . . . . . . . . . . . . . 2-4
  104.  
  105.            Next character from keyboard (NEXCHAR). . . . . . . . . . . 2-4
  106.  
  107.     WRITE STATEMENTS . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
  108.            Unformatted . . . . . . . . . . . . . . . . . . . . . . . . 2-5
  109.            formatted . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
  110.            List directed . . . . . . . . . . . . . . . . . . . . . . . 2-6
  111.  
  112.            SHOW_CHAR (display a character on screen) . . . . . . . . . 2-6
  113.            CRLF  (write cr,lf to specified IOCB) . . . . . . . . . . . 2-6
  114.  
  115.     FORMAT STATEMENTS  . . . . . . . . . . . . . . . . . . . . . . . . 2-7
  116.            Field and edit descriptors. . . . . . . . . . . . . . . . . 2-7
  117.  
  118.     ARITHMETIC EXPRESSIONS . . . . . . . . . . . . . . . . . . . . . . 3-1
  119.            INC, DEC  (incrementing and decrementing variables. . . . . 3-1
  120.            ADD, SUB  (adding to, or subtracting from variables . . . . 3-1
  121.            Subscripts  . . . . . . . . . . . . . . . . . . . . . . . . 3-2
  122.  
  123.     
  124.     
  125.        CONTROL STATEMENTS
  126.               TEST, TEST Numeric. . . . . . . . . . . . . . . . . . . . . 4-1
  127.               Control flags . . . . . . . . . . . . . . . . . . . . . . . 4-1
  128.               Conditional transfers . . . . . . . . . . . . . . . . . . . 4-1
  129.    
  130.               Compare variable to constant, CMP . . . . . . . . . . . . . 4-2
  131.               Compare string to string  . . . . . . . . . . . . . . . . . 4-2
  132.               Unconditional transfers, GOTO, JMP  . . . . . . . . . . . . 4-2
  133.               WAIT  . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
  134.               PAUSE . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
  135.               STOP, CALL EXIT . . . . . . . . . . . . . . . . . . . . . . 4-2
  136.     
  137.               TABLE_LOOKUP  . . . . . . . . . . . . . . . . . . . . . . . 4-3
  138.     
  139.               IF statements . . . . . . . . . . . . . . . . . . . . . . . 4-4
  140.               Block IF  . . . . . . . . . . . . . . . . . . . . . . . . . 4-5
  141.               Do-loops  . . . . . . . . . . . . . . . . . . . . . . . . . 4-8
  142.     
  143.        RESERVED WORDS AND ARRAYS. . . . . . . . . . . . . . . . . . . . . 5-1
  144.               The command line (command tail) . . . . . . . . . . . . . . 5-1
  145.               Useful program constants  . . . . . . . . . . . . . . . . . 5-1
  146.    
  147.     
  148.        Miscellaneous Intrinsics . . . . . . . . . . . . . . . . . . . . . 6-1
  149.               COPY Array_1 to Array_2 . . . . . . . . . . . . . . . . . . 6-1
  150.               FIND_CHAR 'c', Array  . . . . . . . . . . . . . . . . . . . 6-1
  151.               END  Ignored by the compiler. . . . . . . . . . . . . . . . 6-1
  152.               Masking operations.  AND, XOR, OR . . . . . . . . . . . . . 6-1
  153.               SHIFT Shift a variable. . . . . . . . . . . . . . . . . . . 6-1
  154.               PARSE String, Keword  . . . . . . . . . . . . . . . . . . . 6-1
  155.               PARSE_ONLY String, Keword, 'char' . . . . . . . . . . . . . 6-1
  156.               LDA.  Load address  . . . . . . . . . . . . . . . . . . . . 6-2
  157.               UPCASE.  Convert string to upper case . . . . . . . . . . . 6-2
  158.     
  159.        SYSTEMS STUFF  . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3
  160.               EXCLUDE_RTL . . . . . . . . . . . . . . . . . . . . . . . . 6-3
  161.               LABEL  variable, word/byte. . . . . . . . . . . . . . . . . 6-3
  162.               PRESET data-type,variable . . . . . . . . . . . . . . . . . 6-3
  163.               SETFORM 'c' . . . . . . . . . . . . . . . . . . . . . . . . 6-3
  164.               SETIF 'c' . . . . . . . . . . . . . . . . . . . . . . . . . 6-3
  165.    
  166.    
  167.        Ramdisk  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-1
  168.    
  169.        Known bugs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-1
  170.  
  171.  
  172.  
  173.                      INTRODUCTION TO SBM FORTRAN
  174.  
  175.     This manual describes  SBM FORTRAN.  SBM is based on American National
  176.     Standards Institute FORTRAN 77 language.  It is assumed that the reader
  177.     has knowledge of an existing FORTRAN language and is familiar with MSDOS
  178.     or PCDOS operating system.  This manual is not intended to teach
  179.     FORTRAN, but is intended to be used as reference material only.
  180.  
  181.     The original intention of SBM fortran was the author's answer to the 'C'
  182.     language. The cryptic nature of 'C', while appealing to many
  183.     programmers, leaves me cold. While I fully appreciate the power of the
  184.     'C' language (as with assembler), I felt that there was needed something
  185.     that would better suit my style.
  186.  
  187.     I also remember when I brought my first XT home. There were many
  188.     fortran-written utilities that I had on the Z-80 without which I felt
  189.     very helpless. By the time I had rounded up the money to buy the system,
  190.     I had none left for the software that I very sorely needed.  An
  191.     affordable compiler of an easily learned language seemed to the the
  192.     answer.  A good reason  for someone, such as I, to write SBM fortran.
  193.  
  194.     The powerful fortran systems that are now on the market are designed with
  195.     the high-level user in mind.  Program size is not important.  I needed
  196.     something that would generate about the same code as if I wrote the it in
  197.     assembler.
  198.  
  199.     This compiler operates by converting FORTRAN source code into assembler
  200.     instructions,  which are then converted into machine code using WASM, an
  201.     assembler written by ERIC TAUK, of Merengo, IL.  The result is a COM
  202.     file, which can then be run on any MSDOS based system.
  203.  
  204.     THIS IS VERSION 1.00. To most of us this means a system that works well
  205.     enough for the author, but sometimes awkward for the user. Here is a
  206.     problem. I am in the process of moving to Wyoming.  Here in Denver, I
  207.     have access to many excellent bulletin boards. In Wyoming, that will
  208.     not be the case. I must therefore release this version knowing that
  209.     there may be bugs.  Since I will no longer have easy access to the
  210.     boards, I will not longer have easy access to you, the user. I must
  211.     therefore go to a 'shareware' mode.
  212.  
  213.     To provide this connection, You must send me your name and mailing
  214.     address. That will make you a registered user. To receive ANY updates of
  215.     this compiler, you MUST be a registered user. At a minimum, I will
  216.     upgrade to provide some of the functions that I need. Registered users
  217.     will receive the first (or most recent) update. I most certainly need
  218.     your suggestions for improvements and bug removal. If you like this
  219.     compiler as I believe you will, your $20 contribution will be
  220.     appreciated.  Since I will no longer have access to the boards, that's
  221.     the only way that you can receive the update.
  222.  
  223.  
  224.  
  225.     MSDOS is a registered trademark of Microsoft Corporation.
  226.     PCDOS is a registered trademark of IBM Corporation.
  227.  
  228.  
  229.  
  230.  
  231.  
  232.                                    iii
  233.  
  234.     
  235.     
  236.        FEATURES OF SBM FORTRAN
  237.     
  238.        It is a compiler compiler.  It was conceived as a bootstrap system to
  239.        compile parts of itself.  That's why I refer to it as my answer to 'C'.
  240.     
  241.        You can insert assembler coding and macros.  You can invoke the standard
  242.        interrupts.  In other words, you can do anything with this compiler that
  243.        you can do in assembler.  In fact, some of the more complex modules of
  244.        the compiler are WRITTEN IN FORTRAN.  Any future refinements will be
  245.        written in fortran.
  246.     
  247.        The executable module is very compact and efficient compared to other,
  248.        higher-level compilers.
  249.     
  250.        It combines the simplicity of fortran coding with the power of the
  251.        assembler.
  252.     
  253.        You can operate it as you would any other F77 compiler and end up with
  254.        code that will usually run on any other F77 compiler.
  255.     
  256.        You can place more than one statement on each record.
  257.     
  258.        You can append comments to each statement.
  259.     
  260.        The compiled module uses buffered input, making it very fast. 
  261.        Pathnames are used so that  you can access data on other drives and
  262.        in other directories.
  263.     
  264.        All console/keyboard i/o can be re-directed.
  265.     
  266.        It has many powerful intrinsic operations, such as:  PARSE, COPY,
  267.        TABLE-LOOKUP, COMPARE, etc..
  268.     
  269.        You can do masking operations, such as AND, OR, XOR.
  270.     
  271.        You can shift variables left or right, by the number of bits that you
  272.        specify.
  273.     
  274.    
  275.    
  276.    
  277.    
  278.    
  279.    
  280.    
  281.    
  282.    
  283.    
  284.    
  285.    
  286.    
  287.    
  288.    
  289.    
  290.                                      iv
  291.  
  292.  
  293.  
  294.     CURRENT STATUS OF SBM FORTRAN
  295.  
  296.     BE VERY CAUTIOUS USING ANY SORTWARE!  Do not trust it!  Even if you
  297.     have been using it for awhile, mentally EDIT the output.  Does it look
  298.     reasonable?  You are the best judge.
  299.  
  300.     SBM fortran is not a  scientific compiler. i.e., it does not have
  301.     floating point.
  302.  
  303.     Integer*4 is there, but needs more hooks before it can be used.
  304.  
  305.     Arithmetic expressions are primitive, but gramatically correct and
  306.     transportable.  This feature will be upgraded to some extent.
  307.  
  308.     Needs more diagnostic messages.  SBM fortran is not just forgiving. It's
  309.     actually permissive.
  310.  
  311.     But, on the other hand, if you accept the above limitations, and write a
  312.     program using standard fortran coding techniques, it will work, and the
  313.     code can be put up and run under most other F77 compilers, without
  314.     modification.
  315.  
  316.  
  317.  
  318.  
  319.     FUTURE OF SBM FORTRAN
  320.  
  321.     SBM fortran was not, and is not intended to be a full-blown fortran
  322.     compiler. It is not intended to compete with the more powerful
  323.     systems.
  324.  
  325.     Integer*4 is one feature that will certainly be implememted. With large
  326.     integers, you can do quite a lot.  Accounting work and other related
  327.     types of work require precise calculations. Large integers makes that
  328.     precision possible. Instead of dollars and cents, you can carry
  329.     everything in total cents. i.e. $156.25 is 15625 cents. For output,
  330.     the format statement can direct that a decimal point be inserted (this
  331.     feature is already installed, but not yet usable).
  332.  
  333.     The compiler needs compile time and runtime error detection that it does
  334.     not now have. Some errors simply lock up the system.  That is something
  335.     that must be addressed in the first update.
  336.  
  337.     The direction of its future is mostly up to you.  I have some floating-
  338.     point routines that could be implemented, but I will probably not work in
  339.     that direction unless there's enough response.  The routines are in
  340.     another  fortran compiler of mine which I chose not to release at this
  341.     time.
  342.  
  343.  
  344.     There's  another feature, TONTO (trace-on, trace_off), that might also be
  345.     moved  from my other compiler.
  346.  
  347.                                     v
  348.  
  349.                                                                             1-1
  350.     
  351.        FORTRAN STATEMENTS
  352.     
  353.        There are two types of statements, executable and non-executable.
  354.     
  355.        Non-executable statements are used to describe the characteristics and
  356.        format of data.
  357.     
  358.        Executable statements specify actions that the program is to take
  359.        against, or for the welfare of the data, such as READ, WRITE, etc..
  360.     
  361.        Each source input line can be as long as 80 characters.  Statement
  362.        Continuations are permitted only on certain statements.  they are:
  363.                OPEN, FORMAT, data initialization.
  364.     
  365.        You can use statement labels to identify and reference individual
  366.        statements in a program.  You can label any statement but only labled
  367.        statements can be referenced.
  368.     
  369.     
  370.        SYMBOLIC NAMES AND KEYWORDS
  371.     
  372.        Symbolic names, chosen by the programmer, identify program variables and
  373.        statement lables.  A keyword is a pre-assigned identifier that you use to
  374.        specify a particular action that the program is to take. Keywords are
  375.        also known as RESERVED WORDs (see 5-1).
  376.     
  377.        A symbolic name is a sequence of one to 31 alphanumeric characters.
  378.     
  379.        When used to identify program variables, the first character must not be
  380.        numeric.  The name may consist of just about any printable character
  381.        except for + - * / ( ) ; | apostrophy or comma.  You cannot use reserved
  382.        words to identify program variables.
  383.     
  384.        Standard fortran labels consist of numeric lables only.  SBM fortran
  385.        allows either, except for lables of format statements, which must begin
  386.        with a numeric digit 0-9. Lables cannot begin with + - * ; |. Lables
  387.        cannot use ( ) [ ] apostrophy or comma.  Reserved words may be used as
  388.        lables.
  389.     
  390.        Statement lables must begin in column 1.  All other statements must begin
  391.        in  any column other than 1. By all means use column 7 if you wish to
  392.        adhere to an accepted standard.
  393.     
  394.        You can assign more than one lable to a statement if you wish.  In doing
  395.        so, you can refer to it by either label.
  396.     
  397.     
  398.        More than one statement may appear on each source input record by
  399.        terminating each (except the last) with the marker code '|'. (on most
  400.        keyboards this is uppercase backslash)  The format of the additional
  401.        statements is no different than the first, so don't forget to follow the
  402.        marker with at least one blank, unless it is to be a label.
  403.     
  404.     
  405.     
  406.        STATEMENT ORDER
  407.     
  408.        Doesn't matter. mix or match. the compiler will sort them out.
  409.  
  410.     1-2
  411.  
  412.     COMMENTS - You can use a semi-colon(;), an asterisk(*) or hyphen (-) in
  413.     column 1 to specify that the line is a comment. In addition, if you place
  414.     a ';' anywhere in the statement portion of a source line, the rest of
  415.     that statement will be treated as a comment. A blank line is also
  416.     considered to be a comment.
  417.  
  418.     Individual assembler code statements can be inserted anywhere by placing
  419.     a plus (+) in column 1.
  420.  
  421.  
  422.     INCLUDE
  423.  
  424.     Blocks of fortran statements, assembler code, and macros may be inserted
  425.     using the INCLUDE option.
  426.  
  427.     Syntax:    INCLUDE pathname   Pathname can name any file that is
  428.                                   currently on line, on any disk.
  429.  
  430.     To include assembler code or macros, the statement must have a '+' in
  431.     column 1 and the pathname must be in quotes.
  432.  
  433.     Example:  +   include 'maclib.asm'
  434.  
  435.  
  436.     A small macro library is provided to generate some of the code that the
  437.     compiler needs.  You may build one of your own choosing and insert it
  438.     using the + INCLUDE option.
  439.  
  440.  
  441.                                                                             1-3
  442.     
  443.        DATA TYPES
  444.     
  445.    *   SBM provides three data types: BYTE,  WORD and Doublewords.
  446.     
  447.        BYTE data occupies 8 bits (one byte) of memory and is normally only used
  448.        for ascii characters and strings, or logical variables, such as
  449.        programmer-specified switches and flags. You can use this data type for
  450.        numerical values, up to 255.
  451.     
  452.        WORD data are numbers that are whole positive, negative or zero-value
  453.        numbers. WORD data values occupy 16 bits (two bytes) of memory and can
  454.        contain numbers from -32,768 to 32,767. Although a word can hold a number
  455.        as large as 65,635, this implementation provides no standard way to
  456.        output the larger numbers.
  457.     
  458.    *   DOUBLEWORDs are 32-bit (integer*4) integers. The may contain numbers
  459.        within the range -2,147,483,648 to +2,147,483,647. Integer*4 data is very
  460.        useful for accounting applications where larger numbers are involved and
  461.        precision is required in transactions. For example, monitary amounts can
  462.        be set into integer*4 variables using total cents, rather than dollars
  463.        and cents. When the results are to be printed, a special feature of
  464.        integer*4 values allows you to insert decimal points where applicable.
  465.     
  466.     
  467.        In SBM FORTRAN, the following mean the same:
  468.     
  469.        CHARACTER, BYTE, INTEGER*1, LOGICAL       8-bit data.
  470.     
  471.        INTEGER, WORD, INTEGER*2                 16-bit data.
  472.     
  473.     
  474.        CHARACTER strings appear in memory as a collection of ASCII characters
  475.        terminated by a binary zero.  This zero terminator controls all
  476.        operations in which this data type is manipulated, such as compares,
  477.        copys, input-output, etc.. With the terminator, this is known as as
  478.        an ASCIIZ string.
  479.     
  480.     
  481.     
  482.     
  483.     *  Integer*4 is not totally implemented.  Some parts of it are. Some not.
  484.        I wouldn't recommend that you try it yet. It will be implemented in the
  485.        next update.
  486.  
  487.     1-4
  488.  
  489.     QUOTED STRINGS
  490.  
  491.     Over the years, we programmers have created a standard that would not be
  492.     acceptable to people other than programmers. That is, calling an
  493.     apostrophy a quote! When we think of quoted strings, we think of an ascii
  494.     string enclosed in apostrophies, not quotes. Don't know how this started,
  495.     but we all do it. Anyway, format statements sometimes require us to
  496.     specify a 'quoted' string for output. With this in mind, in this manual,
  497.     when we talk of a quoted string, we mean a string that is enclosed in
  498.     apostrophies.
  499.  
  500.     When entering a quoted string that we wish wish to contain an imbedded
  501.     quote, SBM FORTRAN requires that you use an ACTUAL quote(").  Standard
  502.     fortran wants you to use two apostrophies in a row.  We do it differently
  503.     here.
  504.  
  505.  
  506.  
  507.     example:  standard fortran requires:
  508.  
  509.               FORMAT('We sometimes don''t follow standards')
  510.  
  511.  
  512.  
  513.     We do it this way:
  514.  
  515.               FORMAT('We sometimes don"t follow standards')
  516.  
  517.  
  518.  
  519.  
  520.                                                                             1-5
  521.     
  522.        DATA DECLARATION and INITIALIZATION
  523.     
  524.     
  525.        There are two modes in which you can declare variables, (1) declare and
  526.        (2) declare/initialize.
  527.     
  528.          (1) Declare.  The 'standard' declaration in which you specify the size
  529.          of individual elements and optionally set aside a specific amount of
  530.          memory to contain these elements in an array.
  531.     
  532.              Example:  INTEGER ELEV(20), DIST(20), SLOPE, DELTA(3)
  533.     
  534.        (2) Declare/initialize. This mode allows you to declare a variable or an
  535.        array and establish it's initial value(s). When initializing arrays, only
  536.        as much memory as needed to contain the given data will be allocated.
  537.        This statement can be continued. When used, this option must be the last
  538.        (or only) declaration on the source statement. You can, of course, put
  539.        multiple statements on one physical record. Examples:
  540.     
  541.            integer day/5/|   integer month/12/|   integer year/1948/
  542.     
  543.            integer*1 level(4), mace/3/
  544.     
  545.            character pathname/'c:sales.jan',0/
  546.     
  547.     
  548.          This statement is tricky.  If you forget the closing '/', the compiler
  549.          will search the rest of your source looking for one.
  550.     
  551.          Here's another example, taken right out of the compiler itself:
  552.     
  553.            character registers/
  554.              'AX',0,'BX',0,'CX',0,'DX',0,'SI',0,'DI',0,'BP',0
  555.              'AL',0,'BL',0,'CL',0,'DL',0,'AH',0,'BH',0,'CH',0
  556.              'DH',0,'[SI]',0,'[DI]',0,'[BX]',0,'[BP]',0,'$'/
  557.     
  558.        If you want to declare an array of a certain size but initialize only the
  559.        first portion, here's another example from the compiler:
  560.     
  561.            character outbuf(80)
  562.            data outbuf/'e:sbm.t$$',0/
  563.     
  564.     
  565.     
  566.        THE DATA STATEMENT
  567.     
  568.        This is an executable statement!  Most fortran reference manuals don't
  569.        admit it but it is.  Because of this fact, it can be used anywhere in
  570.        the program.  As you see above, you can initialize a variable or an
  571.        array with it.  You can also change data values on the fly. Over and
  572.        over.
  573.     
  574.        Here's a handy use of this feature:
  575.     
  576.           If(code.eq.4) DATA table/1,2,3,4,5/
  577.           If(code.eq.5) DATA table/6,7,8,9,0/
  578.  
  579.                                                                             2-1
  580.     
  581.        OPEN statement
  582.     
  583.        The OPEN statement establishes the connection between a fortran UNIT and
  584.        a file or device. You must issue this statement before any diskfile I/O
  585.        can be used. Note: you cannot close a file and re-open.
  586.     
  587.        syntax:
  588.     
  589.        OPEN(UNIT,ALIAS=buff-name,FILE='filespec',status='old/new/append',
  590.                                                                      RECL=nnn)
  591.     
  592.        where:
  593.     
  594.        UNIT is a numeric constant, in the range of 5-255.
  595.     
  596.        The unit number is converted to a control block name by appending the
  597.        number to 'IOCB_'. The unformatted input record can be referenced by this
  598.        name (as well as any alias that you may specify). Unit 10, for example
  599.        may be referenced by the name 'IOCB_10'. An example of this can be found
  600.        under UNFORMATTED READ.
  601.     
  602.        ALIAS is an alternate name by which the file can be addressed when
  603.        reading unformatted (raw) data. Raw mode, when used instead of formatted
  604.        or list-directed input results in much faster i\o. Unformatted i/o is
  605.        discussed more fully in READ statements. This parameter is optional.
  606.     
  607.     
  608.        FILE='filespec'. Pathnames can be used here. You may name a file that is
  609.        to be used, or specify a character array which contains an ASCIIZ
  610.        filespec. If the name itself is used here, it must be enclosed in quotes.
  611.        If an array containing the filespec is used, it must not be quoted.
  612.     
  613.     
  614.        STATUS='old/new/append'. If the file is to be created, use 'new'. If the
  615.        file is to be read/write, use 'old'. If you have an existing file that is
  616.        to be enlarged, use 'append'. If you use 'new', any existing file by that
  617.        name will be replaced. If you omit this parameter, 'old' is assumed. The
  618.        quotes are optional, for compatability.
  619.     
  620.     
  621.        RECL=nnn. SBM uses a buffered input system, resulting in very high-speed
  622.        input.  The buffering system uses two arrays.  one for the input buffer,
  623.        (into which is loaded blocks of non-predictable pieces) and the record
  624.        buffer which will contain only the individual record.  It is from the
  625.        record area that formatting takes place.  You can use the RECL option to
  626.        insure that no record exceeds a given size.  If this option is omitted,
  627.        record length defaults to 80.
  628.  
  629.     2-2
  630.  
  631.     READ STATEMENTS
  632.  
  633.     READ statements transfer data from a specified I/O unit to memory.  You
  634.     can reference both external and internal files.  The input data may be
  635.     any ASCII stream.
  636.  
  637.     Syntax:   READ(UNIT [,FMAT]) list
  638.  
  639.  
  640.     UNIT is one of:
  641.  
  642.         (1) An integer constant in the range of 5 to 255 that identifies an
  643.             external unit previously referenced in an OPEN statement.
  644.  
  645.         (2) An asterisk (*) specifying the default I/O unit (console).
  646.             May be redirected.
  647.  
  648.         (3) The name of an internal array (such as the input buffer)
  649.             containing data. This is the manner by which you can re-read
  650.             a data record.  explanation:  on any read, the data is read into
  651.             the input buffer as raw data.  If a format has been specified,
  652.             the record is transformed into the corresponding input fields.
  653.             But: even after formatting, the raw data is still in the input
  654.             buffer.
  655.  
  656.     FMAT is a parameter that specifies whether explicit or list-directed
  657.             formatting is to be applied. It may take either of the following
  658.             forms.
  659.  
  660.          (1) A statement label of a format statement. The statement label
  661.              must begin with a numeric character 0-9. The rest of the label
  662.              can be anything of your own choosing.
  663.  
  664.          (2) '*' that specifies list-directed formatting.
  665.  
  666.  
  667.     If FMAT is omitted, a 'null' read is performed, effectively passing over
  668.     an input record.  The unformatted contents of the record are not lost,
  669.     however, but are preserved in the input-output control buffer (IOCB).
  670.     The string is available by its IOCB name, and may be treated as any
  671.     other character array.
  672.  
  673.  
  674.     LIST names the variables, arrays, array elements and character strings
  675.     to which data will be transferred.
  676.  
  677.     If end of file is sensed, the logical variable 'EOF' is set to TRUE.
  678.  
  679.                                                                             2-3
  680.     
  681.        UNFORMATTED READ
  682.     
  683.     
  684.        Syntax:   READ(UNIT) list
  685.     
  686.        This is the most simple of the input statements.  It transfers one
  687.        record of binary data to the array 'list'.  No conversion takes place.
  688.        (A typical file of data information is stored as ASCII characters. No
  689.        conversion is required if all you want to do is to examine it.  It is
  690.        considered to be binary data)
  691.     
  692.     
  693.        If 'list' is omitted, one record is by-passed.  For that reason it is
  694.        sometimes referred to as a 'null' read, or 'by-pass' read.
  695.     
  696.        The contents of the record are available in the IOCB or under the ALIAS
  697.        that was specified in the 'open'.
  698.     
  699.        Here's an example of how you might use it to read and display a file.
  700.     
  701.     
  702.                 open(5,file='reform.for')
  703.            1000 read(5)
  704.                 if(eof) stop
  705.                 write(*) iocb_5
  706.                 goto 1000
  707.                 end
  708.     
  709.        Type this one in and try it. It will make your hair stand on end! If you
  710.        were to try this example on a large file, you can see that it wouldn't do
  711.        you much good. The output would fly by so fast that you couldn't read
  712.        most of it.
  713.  
  714.     2-4
  715.  
  716.     FORMATTED READ
  717.  
  718.     Syntax:   READ(UNIT,FMAT]) list
  719.  
  720.     This is a two-step operation.
  721.  
  722.     Step 1 reads the record into the IOCB (an unformatted read).
  723.  
  724.     Step 2 applies the formatting and transforms the ascii data into the
  725.     various input fields.
  726.  
  727.  
  728.  
  729.  
  730.     LIST-DIRECTED READ
  731.  
  732.     Syntax:   READ(UNIT,*) list
  733.  
  734.     Read statements are either unformatted or formatted. The difference in a
  735.     list-directed read is that the compiler is going to create a format for
  736.     itself, based on what kind of data we have in the 'list'.
  737.  
  738.     This is a two-step operation.
  739.  
  740.     Step 1 reads the record into the IOCB (an unformatted read).
  741.  
  742.     Step two applies the compiler-designed formatting and transforms the
  743.     ascii data into the various input fields.
  744.  
  745.  
  746.  
  747.  
  748.     NEXCHAR
  749.  
  750.     Reads a character from the keyboard.  Does not echo to the console. If
  751.     no character is ready, waits for operator to enter one.  The character
  752.     is available to the program in register AL.  Execution resumes.
  753.  
  754.     See 'testall.for' for a practical example. (NEXCHAR and WAIT are same)
  755.  
  756.                                                                             2-5
  757.     
  758.        WRITE STATEMENTS
  759.     
  760.        WRITE statements transfer data from memory to a specified I/O unit. You
  761.        can reference both external and internal files.
  762.     
  763.        Syntax:   WRITE(UNIT [,FMAT]) list
  764.     
  765.     
  766.     
  767.     
  768.     
  769.        UNFORMATTED WRITE
  770.     
  771.     
  772.        Syntax:   WRITE(UNIT) list
  773.     
  774.        This statement transfers one record of ascii data to UNIT. The data must
  775.        be terminated by a binary zero. No formatting takes place.
  776.     
  777.        If 'list' is present, it must be the name of an array.  If omitted, the
  778.        formatted contents of the IOCB is written.
  779.     
  780.        This is the form of output that you should use to insert control
  781.        characters, such as escape-sequences, extra line feeds, backspaces, etc.
  782.     
  783.        Example, from 'testall.for'
  784.     
  785.                 data outbuf/esc,'[2J',0/
  786.                 write(*) outbuf  ; clear the screen
  787.     
  788.     
  789.     
  790.     
  791.     
  792.        FORMATTED WRITE
  793.     
  794.        Syntax:   WRITE(UNIT,FMAT]) list
  795.     
  796.        This is a two-step operation and is the revese of formatted read.
  797.     
  798.        Step 1 formats the specified data fields from binary to decimal as
  799.        required and copies ascii data or quoted strings into the IOCB.
  800.     
  801.        Step 2 writes the contents of the IOCB to the specified UNIT.
  802.     
  803.  
  804.     2-6
  805.  
  806.     LIST-DIRECTED WRITE
  807.  
  808.     Syntax:   WRITE(UNIT,*) list
  809.  
  810.     In a list-directed write, a format is constructed by the compiler based
  811.     upon the data type of the various fields. Other than that, it is exactly
  812.     like the formatted write.
  813.  
  814.     While most compilers require that the first character of an output record
  815.     be used for carriage control, SBM fortran does not. When output is to be
  816.     directed to a printer, feel free to insert ascii control codes, 0Ch for
  817.     eject, 0Dh for double space.
  818.  
  819.  
  820.  
  821.  
  822.     SHOW_CHAR
  823.  
  824.     Display the character that is in the AL register.  You can use this
  825.     statement immediately after NEXCHAR.
  826.  
  827.  
  828.  
  829.  
  830.     SHOW_CHAR  'char'
  831.  
  832.     Display specific character.  The character can be a printable
  833.     character enclosed in quotes, or a hex constant.
  834.     Example:    show_char 8   gives us a back-space on the console.
  835.  
  836.  
  837.                                                                             2-7
  838.     
  839.        FORMAT STATEMENTS
  840.     
  841.        Format is a labled non-executable statement that specifies the format of
  842.        data being transferred between memory and i/o devices. It may appear
  843.        anywhere in the program. The first character of the label must be
  844.        numeric. The method by which formatting takes place is by the use of
  845.        field and edit descriptors with which the type and size of the various
  846.        data fields is specified and quoted strings for constant ascii data.
  847.     
  848.        Each field descriptor consists of letter which identifies the type of
  849.        data, followed by a number indicating the width of the data field. In
  850.        some cases the width is optional.
  851.     
  852.        Format control proceeds from left to right, matching each field
  853.        descriptor with each item in the i/o list.
  854.     
  855.        SBM uses 3 field descriptors, A, I, X
  856.     
  857.        Character data.
  858.        The 'A' field descriptor transfers character data.  It has the form
  859.     
  860.            A[w]
  861.     
  862.        If W is present the field width is w-characters. If omitted, the field
  863.        width is the size of the data item in the i/o list. The name in the list
  864.        can be any data type, character, logical or integer. On input, any
  865.        existing data is simply overlayed.
  866.     
  867.     
  868.        Integer data   I[w]
  869.     
  870.        If the output binary number, when converted to decimal, exceeds the
  871.        allocated space, the number will back-flow into the previous field,
  872.        replacing whatever the formatter just put there. (not like standard
  873.        fortran, which would fill the output field with asterisks. If enough of
  874.        you complain, I will comply with the standard).
  875.     
  876.     
  877.        Skip    [w]x
  878.     
  879.        Quoted strings.
  880.     
  881.     
  882.        Dollar sign descriptor  $
  883.     
  884.        Normally, all output records are terminated by a carriage return. The
  885.        dollar sign descriptor inhibits this action. The option is intended for
  886.        interactive I/O and is valid only for output statements. It permits user
  887.        response to appear on the same line as a prompt.
  888.     
  889.        example:   WRITE(*,*) 'Enter project number: ',$
  890.                   READ(*,*) PROJ
  891.     
  892.        When used, the dollar sign descriptor must the the last item of the
  893.        output statement.
  894.  
  895.                                                                             3-1
  896.     
  897.        ARITHMETIC EXPRESSIONS
  898.     
  899.        SBM fortran does not yet support more than a simple one-function
  900.        expression.  The simpler form of an expression, while requiring more
  901.        statements to complete some calculations, still maintains compatability
  902.        with higher-level compilers.
  903.     
  904.        Thus, we are limited to such statements as:
  905.     
  906.                 counter=counter+1
  907.                 range=limit-base
  908.                 etc..
  909.     
  910.        String expressions allow a little more versatility, such as:
  911.     
  912.                 filespec='c:modemuf.asm'
  913.                 letter='A'
  914.                 etc..
  915.     
  916.     
  917.        In addition to the above arithmetic statements, SBM fortran also supports
  918.        the following statements:
  919.     
  920.        INC, DEC      Add or subtract 1 from an integer variable.  This is the
  921.                      most efficient way to add or subtract the constant 1 from
  922.                      a variable.
  923.     
  924.                      example:    inc counter    ; add one to 'counter'
  925.                                  dec tally      ; subtract one from 'tally'
  926.     
  927.     
  928.     
  929.        ADD, SUB      Add or subtract constant or value from register from an
  930.                      integer variable.  This is much faster than standard
  931.                      fortran and uses less code.
  932.     
  933.                      example:    add index,10        ; add 10 to index.
  934.     
  935.                                  index=index+10      ; the usual, less
  936.                                                      ; efficient way.
  937.     
  938.     
  939.     
  940.  
  941.     3-2
  942.  
  943.     SUBSCRIPTING
  944.  
  945.  
  946.     Any variable may be accessed by using the variable name in a fortran
  947.     statement. To access variables in positions other than the first, you
  948.     must (1) use an integer offset or (2) use a subscript.
  949.  
  950.     An integer offset may be used by simply appending the variable name with
  951.     a plus-or-minus constant. Example: 'ARRAY+4' points to the fifth
  952.     position of a integer*1 or character array. If the array was integer*2,
  953.     it would point to the third position, since each element in an integer*2
  954.     array requires two positions. While this is not a standard fortran
  955.     method of accessing data, it is by far the most efficient.
  956.  
  957.     Subscripts, on the other hand, indicate the position of an element by
  958.     enclosing a subscript expression within a pair of parentheses.
  959.  
  960.     The subscript expression can be an integer constant, and integer
  961.     variable, or an integer variable plus-or-minus an integer constant.
  962.  
  963.       Examples: array(k), date(m+2), etc..
  964.  
  965.     Other informative examples can be found in the program 'TESTALL.FOR'.
  966.  
  967.  
  968.     A word of caution: Do not allow the expression to go negative. You will
  969.     access something, but who knows what...
  970.  
  971.                                                                             4-1
  972.     
  973.                                CONTROL STATEMEMTS
  974.     
  975.        There's no point in writing a program if you can't control what it does.
  976.        Without flow control, a program would sequentially execute each of your
  977.        statements and then blow up. That would be tacky.
  978.     
  979.        Fortran flow control statements provide a means of modifying the normal
  980.        sequemntial flow of execution.
  981.     
  982.        Flow control statements are: TEST, COMPARE, CMP, DO, CONTINUE, GOTO,
  983.        JMP, STOP and CALL EXIT. Some of these are not standard but all are
  984.        handy.
  985.     
  986.     
  987.     
  988.        TEST
  989.     
  990.        Usage:  TEST VARIABLE, MASK
  991.            or  TEST VARIABLE, NUMERIC
  992.     
  993.        You can test a variable using a mask, or TEST NUMERIC.
  994.        
  995.        When a TEST is performed, control flags are set, depending upon
  996.        the results of the test. You must then use an if-statement or
  997.        conditional jump. Control flags are: equal, not equal, zero,
  998.        not zero, carry and not carry.
  999.     
  1000.            (EQ), (NE), (ZR), (NZ), (CY), (NC),  (NUMERIC), (NOT.NUMERIC)
  1001.     
  1002.        CONDITIONAL JUMPs are JNC, JC, JZ, JNZ
  1003.     
  1004.        Using a MASK, you can see if a particular bit or any one of a group
  1005.        if bits is set.  It does this with a logical AND, and sets flags but
  1006.        changes nothing in memory.
  1007.     
  1008.          Example:  see if an integer is odd or even.
  1009.                            test(answer,1)
  1010.                            if(zr) goto even
  1011.                       (or) jz even
  1012.     
  1013.     
  1014.        To test an individual ascii character to determine whether it is
  1015.        numeric or not, use the following syntax:
  1016.     
  1017.        TEST VARIABLE, NUMERIC
  1018.     
  1019.        This checks an ascii character to see if it is within the range of
  1020.        '0' - '9'.  As a result of this test, the logical variable 'numeric'
  1021.        is set to either true or false.
  1022.     
  1023.                Example:  test(inbuf(1),numeric)
  1024.                          if(not.numeric) goto alpha
  1025.  
  1026.     4-2
  1027.  
  1028.                             CONTROL STATEMEMTS
  1029.  
  1030.  
  1031.     CMP variable, constant
  1032.  
  1033.     Compare a variable to a known value. This statement is identical to it's
  1034.     ASM equivalent. Subscripts are not permitted, but offsets can be used.
  1035.  
  1036.     Usage:  CMP  Name, 'A'
  1037.             CMP  Name+2,'B'
  1038.             CMP  Year, 99
  1039.  
  1040.     This statement essentially subtracts the constant from the variable, does
  1041.     not change any values in memory but, sets the control flags. You must
  1042.     then use a conditional jump for program control.
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.     COMPARE
  1049.  
  1050.     Compare a string of characters against a model. Not case sensitive,
  1051.     'TOKEN' should be upper case.
  1052.  
  1053.     Usage:  COMPARE KEWORD, 'TOKEN'
  1054.  
  1055.  
  1056.     Example, from the compiler.
  1057.  
  1058.     -   see if prefix 'byte' or 'word'
  1059.         compare keword,'BYTE'    ;
  1060.         if(eq) goto destin_ok    ; if 'byte' or 'word',
  1061.         compare keword,'WORD'    ; accept it as-is.
  1062.         if(eq) goto destin_ok    ;
  1063.  
  1064.  
  1065.     GOTO          Unconditional transfer of control.
  1066.     JMP           Same as GOTO
  1067.  
  1068.  
  1069.  
  1070.     WAIT
  1071.  
  1072.     Wait for operator. Program execution stops. When operator has pressed
  1073.     any key, execution resumes.
  1074.  
  1075.  
  1076.  
  1077.     PAUSE ['message']
  1078.  
  1079.     Stops, waits for operator. If message included, displays the message.
  1080.     Otherwise, displays the phrase 'FORTRAN PAUSE'. Execution of the program
  1081.     will continue with the press of any key.
  1082.  
  1083.  
  1084.     STOP, CALL EXIT
  1085.  
  1086.     Use either to close all files, update directory and return control
  1087.     to the operating system.
  1088.  
  1089.                                                                             4-3
  1090.     
  1091.        TABLE_LOOKUP
  1092.     
  1093.        Given a character string, tests to see if the string exists in a
  1094.        specified table. Each entry in the table must be enclosed within quotes
  1095.        and must be in upper case. each entry must be followed by binary zero.
  1096.        The table must be terminated by a '$'.
  1097.     
  1098.        If the given string is found to be present in the table, register CX
  1099.        indicates it's relative position in the array. i.e., in the table
  1100.        below, AX=1, BX=2, CX=3, etc.
  1101.     
  1102.        If the string cannot be found, CX=0 and carry-flag is set.
  1103.     
  1104.        Here's a sample table.
  1105.     
  1106.         character registers/
  1107.           'AX',0,'BX',0,'CX',0,'DX',0,'SI',0,'DI',0,'BP',0
  1108.           'AL',0,'BL',0,'CL',0,'DL',0,'AH',0,'BH',0,'CH',0
  1109.           'DH',0,'[SI]',0,'[DI]',0,'[BX]',0,'[BP]',0,'$'/
  1110.     
  1111.        The following example wants to see if the character string that is in
  1112.        the array 'keword' is any of the entries in the table 'registers'.
  1113.     
  1114.        -   see if a destination is register.
  1115.            table_lookup keword,registers
  1116.            if(nc) goto destin_ok
  1117.     
  1118.     
  1119.     
  1120.     
  1121.        TABLE_ADD
  1122.     
  1123.        Following a table-lookup operation, adds a string to a given table.
  1124.        While this is not a control statement, it is included here because it
  1125.        is frequently used immediately following a non-successful table_lookup.
  1126.     
  1127.        Example:  install the string in the array 'keword' in the table.
  1128.     
  1129.        -   new symbol, put it in table.
  1130.            table_add keword
  1131.     
  1132.  
  1133.     4-4
  1134.  
  1135.                             IF statements
  1136.  
  1137.     An IF statement conditionally executes one statement or a block of
  1138.     statements.
  1139.  
  1140.     The IF statement has the form:
  1141.  
  1142.       IF (exp) stmt
  1143.  
  1144.     Where exp is a logical or relational expression.
  1145.  
  1146.  
  1147.  
  1148.     In a LOGICAL IF statement, we have, as the result of a TEST or
  1149.     input/output operation, a condition of true(non-zero) or false(zero). The
  1150.     statement, or block of statements, will be executed only if the condition
  1151.     is true. In a logical IF, exp simply names the logical variable. In
  1152.     addition to the normal variable names, SBM fortran also allows the
  1153.     following:
  1154.  
  1155.                    (EQ), (NE), (ZR), (NZ), (CY), (NC)
  1156.  
  1157.           or    (EOF),  (NOT.EOF),  (NUMERIC), (NOT.NUMERIC)
  1158.  
  1159.     stmt can be any non-labled executable statement, but not another IF.
  1160.  
  1161.  
  1162.     The RELATIONAL IF statement performs an on-the-fly comparison of a
  1163.     variable to a known value.
  1164.  
  1165.     Character-strings can be compared, no matter what their length, but only
  1166.     for EQ or NE. Other operators may be used, but use with caution. The
  1167.     comparison is NOT case sensitive.
  1168.  
  1169.     The relational IF has the following syntax:
  1170.  
  1171.           IF (VARIABLE.OP.Constant) stmt
  1172.  
  1173.     where  OP will be EQ, NE, LT, GT, LE, GE
  1174.  
  1175.     Constant may be (1) numeric,
  1176.                       (2) Ascii character (excluding ';' and '|') , or
  1177.                       (3) AsciiZ string.
  1178.  
  1179.                                                                             4-5
  1180.     
  1181.        There are two types of  IF statements:
  1182.     
  1183.           o  The single IF
  1184.     
  1185.           o  The block IF
  1186.     
  1187.           (The arithmetic IF is not supported by SBM fortran)
  1188.     
  1189.        The single IF statement conditionally executes a single statement. It
  1190.        has the form
  1191.     
  1192.          IF (exp) stmt
  1193.     
  1194.        where:
  1195.          exp is a logical expression.
  1196.     
  1197.          stmt is a single, not continued, fortran statement.
  1198.  
  1199.     4-6
  1200.  
  1201.  
  1202.     The block IF conditionally executes blocks of statements. It has the
  1203.     following form:
  1204.  
  1205.     IF (exp) THEN
  1206.        block
  1207.  
  1208.     ELSE
  1209.        block
  1210.  
  1211.     ENDIF
  1212.  
  1213.     where:
  1214.       exp is a logical expression.
  1215.  
  1216.     THEN must appear on the same line.
  1217.  
  1218.     block is a series of statements, none of which can be another block-IF.
  1219.  
  1220.     The ENDIF terminates the block-IF construct.
  1221.  
  1222.  
  1223.  
  1224.  
  1225.                                                                             4-7
  1226.     
  1227.     
  1228.        There are two types of data which can be compared in an IF statement,
  1229.        numeric or literal. Literals are recognized by the presence of quotes.
  1230.        Here are some examples:
  1231.     
  1232.     
  1233.        * Author used the following program to test out and debug IF statements.
  1234.        integer ibuf
  1235.        write(*,*) 'enter a number: ',$
  1236.        read(*,*) ibuf
  1237.        if(ibuf.eq.100) then
  1238.        write(*,*) '---------------'
  1239.        write(*,*) 'number is equal'
  1240.        else
  1241.        write(*,*) 'number is NOT equal'
  1242.        endif
  1243.        if(ibuf.lt.100) write(*,*) 'number is LT 100'
  1244.        if(ibuf.le.100) write(*,*) 'number is also LE  100'
  1245.        if(ibuf.gt.100) write(*,*) 'number is GT 100'
  1246.        if(ibuf.ge.100) write(*,*) 'number is also GE 100'
  1247.        stop
  1248.     
  1249.           - - - - - - - - - - - - - - - - - - - - - - - -
  1250.     
  1251.        ; this program reformats a WASM LST file to straight ASM format. You
  1252.        ; might want to do this to have a source that has the macros expanded.
  1253.     
  1254.               open(5,file=infile,status='old',recl=132,alias=inbuf)
  1255.        loupe  read(inbuf)
  1256.               if(eof) stop
  1257.               if(inbuf.eq.20h)    goto loupe
  1258.               if(inbuf.eq.'L')    goto loupe
  1259.               if(inbuf+22.eq.20h) goto loupe
  1260.               write(1) inbuf+26
  1261.               jmp loupe
  1262.     
  1263.  
  1264.     4-8
  1265.  
  1266.  
  1267.     DO Statement
  1268.  
  1269.     Here you can specify that a block of statements be executed for a
  1270.     specific number of times.
  1271.  
  1272.  
  1273.     Syntax:   DO label index=first,last
  1274.  
  1275.     where: label is a numeric statement label of a CONTINUE statement which
  1276.            is forward from this statement.
  1277.  
  1278.            index is an integer*2 variable that will be set, and then
  1279.            incremented.
  1280.  
  1281.            first is an integer constant.
  1282.  
  1283.            last is an integer constant.
  1284.  
  1285.  
  1286.  
  1287.  
  1288.     CONTINUE statement
  1289.  
  1290.     Used only in conjunction with the DO statement, this statement is labled
  1291.     and is used as the terminator of the block of statements to be executed.
  1292.  
  1293.  
  1294.     Example:  from "testall.for"
  1295.  
  1296.               do 809 counter=1,10
  1297.               write(16,309) counter
  1298.           309 format('test output record',i3)
  1299.           809 continue
  1300.  
  1301.                                                                             5-1
  1302.     
  1303.        RESERVED KEYWORDS and ARRAYS
  1304.     
  1305.        FORTRAN has many keywords that are meaningful to the compiler, such as
  1306.        IF, READ, WRITE, etc..  In addition to the standard list of reserved
  1307.        keywords, SBM fortran includes some options not provided in other
  1308.        systems:
  1309.     
  1310.     
  1311.        LDA, EXCLUDE, WAIT, JMP, JNC, JC, JZ, JNZ, AND, XOR, OR, SHIFT,
  1312.        SETFORM, SETIF, SHOW_CHAR, INCLUDE, UPCASE, INC, DEC, TEST,
  1313.        ADD, SUB, CMP, LABEL, PARSE, COPY, NEXCHAR, TABLE_LOOKUP, TABLE_ADD,
  1314.        COMPARE, FIND_CHAR, CRLF, PRESET.
  1315.     
  1316.        YOU CANNOT USE RESERVED WORDS AS VARIABLE NAMES, although any of them
  1317.        may be used as statement lables.
  1318.     
  1319.     
  1320.        In addition to the above reserved words, we also have the following
  1321.        arrays, which are  considered as reserved words:
  1322.     
  1323.        COMMAND, CONSOLE, INFILE, WORKBUF, OUTFILE, WORKBUF2.
  1324.     
  1325.     
  1326.     
  1327.        THE COMMAND LINE
  1328.     
  1329.        One of the problems facing the high-level programmer is how to access the
  1330.        data that we entered at the system prompt. SBM fortran sets this data
  1331.        where it can be easily used. The command tail can be located in the
  1332.        character array COMMAND. From there it can be parsed or otherwise used
  1333.        just like any other character array. In addition, the first two tokens
  1334.        are parse into INFILE (alias WORKBUF) and OUTFILE (alias WORKBUF2) and
  1335.        may be used as filenames in the OPEN statement.
  1336.     
  1337.        The advanced programmer will find these options to be of significant
  1338.        value.
  1339.     
  1340.     
  1341.        PROGRAM CONSTANTS
  1342.     
  1343.     
  1344.        Rather than using numerical equivalents for commonly needed constants,
  1345.        you may choose from the following list of pre-assigned symbolic names.
  1346.     
  1347.           CR        Carriage return.  Use instead of 0Dh, 13 decimal.
  1348.           LF        Line feed. Use instead of 0Ah, 10 decimal.
  1349.           ESC       Escape.  For ansi screen control, 1Bh, 27 decimal.
  1350.           FF        Form feed.  To eject the page in printer files.
  1351.           TAB
  1352.           BS        Back space.
  1353.           COMMA     Equivalent to 2Ch.
  1354.           QUOTE     Equivalent to 27h.
  1355.           QUOTES    Equivalent to 22h.
  1356.           False     Equivalent to binary zero.
  1357.           True      Equivalent to binary 1.
  1358.  
  1359.                                                                             6-1
  1360.        MISCELLANEOUS INTRINSIC FUNCTIONS
  1361.     
  1362.    
  1363.    
  1364.        COPY Array_1, Array_2
  1365.     
  1366.        Copies a character string to another array. Can be indexed.
  1367.     
  1368.    
  1369.    
  1370.     
  1371.        FIND_CHAR  'c', Array
  1372.     
  1373.        Searches a character string until the specified character is located.
  1374.     
  1375.    
  1376.        END    Optional for compatability. Ignored by the compiler.
  1377.     
  1378.     
  1379.    
  1380.        AND, XOR, OR  Masking operations
  1381.    
  1382.        Usage:  AND variable,mask.  Mask is hex constant, register, memory.
  1383.    
  1384.    
  1385.    
  1386.     
  1387.        SHIFT         Shift a variable, left or right.
  1388.     
  1389.        Usage:  SHIFT VARIABLE [,nbits]
  1390.     
  1391.        Shifts the variable the number of bits specified. If nbits absent, shift
  1392.        the variable one bit right. Otherwise you must specify the number of
  1393.        shifts. If nbits is preceded by a minus sign, shift is to the left.
  1394.     
  1395.                     Example:  shift 'number' one bit right.
  1396.                               SHIFT NUMBER
  1397.     
  1398.                     nother:   shift 'number' 3 bits left.
  1399.                               SHIFT NUMBER,-3
  1400.     
  1401.        If you  wish to shift only one bit left, it can be more efficiently
  1402.        done by adding the number to itself.  It accomplishes the same result.
  1403.     
  1404.                     Example:  ibuf=ibuf+ibuf
  1405.     
  1406.                     or better yet:   ax=ibuf
  1407.                                      add ibuf,ax
  1408.  
  1409.     6-2
  1410.  
  1411.     MISCELLANEOUS INTRINSIC FUNCTIONS
  1412.  
  1413.  
  1414.  
  1415.  
  1416.     PARSE STRING, KEY  [, 'delims']
  1417.  
  1418.     Given the ascii STRING, isolate the first token. Copy the isolated token
  1419.     to KEY and shift STRING left to remove the token KEY. Delimiters are
  1420.     blank, comma or equals. Carry is set if no data available to parse (EOR).
  1421.  
  1422.     You can specify an  additional list of delimiters to be used.
  1423.  
  1424.     Example:  Consider the string 'now is the-time'
  1425.  
  1426.         parse string,keword,'(/-+'
  1427.  
  1428.     After the parse,  keword will be 'now'
  1429.                       string will be 'is the-time'
  1430.  
  1431.                       carry is not set.
  1432.  
  1433.  
  1434.     PARSE_ONLY String, Keword, 'char'
  1435.  
  1436.     Parse until a specific character is found. We ignore the standard
  1437.     delimiters. In fact, the standard delimiters (including blanks) are
  1438.     passed to the 'keword' array.
  1439.  
  1440.     Example:  As above, the string 'now is the-time'
  1441.  
  1442.         parse_only string, keword,'-'
  1443.  
  1444.     After the parse,  keword will be 'now is the'
  1445.                       string will be 'time'
  1446.  
  1447.  
  1448.  
  1449.     LDA           Load address to a register:      LDA VARIABLE, REG
  1450.  
  1451.  
  1452.     UPCASE        Convert a character string to upper case.
  1453.  
  1454.                   Usage:  UPCASE String
  1455.  
  1456.                                                                             6-3
  1457.        SYSTEMS STUFF
  1458.    
  1459.        Things on this page are of no value to users.  They are included here
  1460.        only for Author's convenience.
  1461.    
  1462.    
  1463.        LABEL  variable, word/byte. Allows alias in system modules.  Must be
  1464.               issued immediately before the data decalaration statement.
  1465.    
  1466.        PRESET data-type,variable   Establish name and type in symbol
  1467.                       table for external variable.  data type is byte/word.
  1468.    
  1469.        SETFORM 'c'    Change default character in format name. Normally
  1470.                       fmt_nnn.  Changes the 't'.  Sample: fma_001.
  1471.    
  1472.        SETIF 'c'      Change default character in if-labels. Normally
  1473.                       true_000.  Changes first '0'.  Sample: true_a01.
  1474.    
  1475.        Example of the above two.       SETFORM a|   SETIF a
  1476.  
  1477.                                                                             7-1
  1478.     
  1479.        Greater speed can be realized by using a ramdisk.  To take advantage
  1480.        of this feature, include in your autoexec.bat file the following:
  1481.     
  1482.           SET RAMDISK=d
  1483.     
  1484.        Where 'd' is your ramdisk drive.  i.e. SET RAMDISK=E
  1485.     
  1486.     
  1487.     
  1488.        In the batch files, notice the commands SET BATCH=TRUE and
  1489.        SET BATCH=.
  1490.     
  1491.        These two commands are used by the compiler to determine the course
  1492.        or action when the requested source file cannot be found.  They are of
  1493.        no concern for normal operations and should not be disturbed.
  1494.    
  1495.  
  1496.                                                                              8-1
  1497.        KNOWN BUGS
  1498.    
  1499.        I am aware of the following bugs.  If I take time to correct them
  1500.        now, I may not get this system on the boards before I move to Wyoming.
  1501.        They will be addressed in the next update.
  1502.    
  1503.    
  1504.        1.  If you re-define a variable, you get no error message but all
  1505.        sorts of seemingly unrelated problems.
  1506.    
  1507.    
  1508.        2. if(inbuf.eq.';')                                SBM.ASM(get_record)
  1509.        Input takes the ';' as begin comment, thereby truncating the statement.
  1510.    
  1511.